export {};

interface DataItf {
  a: number;
  b: number;
}

interface ResItf {
  code: number;
  data: DataItf[] // {a: number, b: number}[]
  message: string;
}

// promise对象   p对象名：Promise<返回类型>
const p: Promise<ResItf> = new Promise((resolve, reject) => {
  resolve({
    code: 200,
    data: [
      { a: 1, b: 2 },
      { a: 3, b: 4 },
    ],
    message: 'ok',
  });
});

p.then(res => {
  if (res.code === 200) {
    res.data.map(item => item.a)
  }
})